package org.example.game.history;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/07/21 10:38
 */
public class Solution100372 {

    public static void main(String[] args) {
        System.out.println(new Solution100372().minChanges(13, 4));
    }


    public int minChanges(int n, int k) {
        if(k>n){
            return -1;
        }else if(n == k){
            return 0;
        }else {
            int count=0;
            while (n > 0){
                int kMode = k % 2;
                int nMode = n % 2;
                if(nMode == 0 && kMode == 1){
                    return -1;
                }else if(nMode != kMode){
                    count++;
                }
                k = k/2;
                n = n/2;
            }
            return count;
        }
    }

}
